<?php

require_once dirname(__FILE__) . '/../../Extension/Params.php';
require_once dirname(__FILE__) . '/TextValues.php';

class Rams_Extension_UsedParams extends Raws_Extension_Params
{
  
  // protected $_rootNamespace = 'raws';
  // protected $_rootElement = 'params';

    # child elements of the params element
    protected $_credits = null;
    protected $_product = null;
    protected $_name = null;

    public function __construct() 
    {
        parent::__construct();
    }
    
    /**
     * Retrieves a DOMElement which corresponds to this element and all
     * child properties.  This is used to build an entry back into a DOM
     * and eventually XML text for application storage/persistence.
     *
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
     * @return DOMElement The DOMElement representing this element and all
     *          child properties.
     */
    public function getDOM($doc = NULL, $majorVersion = 1, $minorVersion = NULL)
    {
        $element = parent::getDOM($doc);
        if ($this->_credits != null) {
          $element->appendChild($this->_credits->getDOM($element->ownerDocument));
        }
        if ($this->_product != null) {
          $element->appendChild($this->_product->getDOM($element->ownerDocument));
        }
        if ($this->_name != null) {
          $element->appendChild($this->_name->getDOM($element->ownerDocument));
        }
        
        return $element;
    }

    /**
     * Creates individual Entry objects of the appropriate type and
     * stores them as members of this entry based upon DOM data.
     *
     * @param DOMNode $child The DOMNode to process
     */
    protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        
        switch ($absoluteNodeName) {
            case $this->lookupNamespace('raws') . ':' . 'credits'; 
                $credits = new Rams_Extension_Credits();
                $credits->transferFromDOM($child);
                $this->_credits = $credits;
                break;
            case $this->lookupNamespace('raws') . ':' . 'product'; 
                $product = new Rams_Extension_Product();
                $product->transferFromDOM($child);
                $this->_product = $product;
                break;
            case $this->lookupNamespace('raws') . ':' . 'name'; 
                $name = new Rams_Extension_Name();
                $name->transferFromDOM($child);
                $this->_name = $name;
                break;

            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }
    
    public function getCredits()
    {
        return $this->_credits;
    }

    public function setCredits($value)
    {
        $this->_credits = $value;
        return $this;
    }

    public function getProduct()
    {
        return $this->_product;
    }

    public function setProduct($value)
    {
        $this->_product = $value;
        return $this;
    }

    public function getName()
    {
        return $this->_name;
    }

    public function setName($value)
    {
        $this->_name = $value;
        return $this;
    }

}
